import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TestLikou
{
        public static List<Integer> findAnagrams(String s, String p)
        {
            int lenp = p.length();
            int lens = s.length();
            int l = 0;
            int r = 0;
            List<Integer> list = new ArrayList<>();
            for( ; r<=lens ; r++)
//            while(r<=lens-lenp+1)
            {

                if(r>=lens)
                {
                    break;
                }
                if(r-l+1 == lenp)
                {
                    int[] cnt = new int[26];
                    int[] cnt1 = new int[26];
                    for(int i=l;i<r+1;i++)
                    {
                        cnt[s.charAt(i)-'a']++;
                    }
                    for(int j=0;j<lenp;j++)
                    {
                        cnt1[p.charAt(j)-'a']++;
                    }
                    int flag =0;
                    for(int i=0;i<26;i++)
                    {
                        if(cnt[i] != cnt1[i])
                        {
                            flag =1;
                        }
                    }
                    if(flag == 0)
                    {
                        list.add(l);
                    }
                    l++;
                }
                r++;
            }
            return list;
        }

    public static void main(String[] args) {
        String s ="acdcaeccde";
        String s1="c";
        findAnagrams(s,s1);
        System.out.println("Test is Ok");
        int nums[] = {1,2,3,455,6};
        int nums1[] = {1,2,3,455,6};
        System.out.println(nums.equals(nums1));
        System.out.println(Arrays.equals(nums,nums1));

    }
}
